/**
 * This program is free software but WITHOUT ANY WARRANTY OR CONDITIONS OF ANY KIND.
 *
 * Copyright (C) 2008 www.pretty-tools.com
 */

function onLoad()
{
    try
    {
        var doc = null, docURL = null, workWindow = null;

        if (typeof external.menuArguments != 'undefined')
        {
            var wnd = external.menuArguments;

            var helper = yrprxComponentsFactory.createInstance("XPCOMAdapter.ContextMenuHelper.1");

            doc = wnd.document;
            docURL = helper.GetDocumentLocation(doc);
        }
        else
        {
            doc = window.arguments[0];
            docURL = window.arguments[1];
            workWindow = window;
        }

        if (!doc)
            throw "Cannot get document";

        var images = g_wsshImageResolver.getImages(doc, false, docURL);
        if (images && images.length)
            wsshWindowManager.openSlideShow(images, doc.title, workWindow);
        else
            yrprxPrompt.alert(wsshResources["webslideshow.title"], wsshResources["webslideshow.can.not.find.appropriate.images"]);
    }
    catch(ex)
    {
        try
        {
            var logger = yrprxFactory.createLogger("context-menu-slideshow.js");
            if (logger.enabled) logger.error("onSlideShow: ", ex);
        }
        catch(ex2)
        {
            dump("Cannot create logger! Exception: " + ex.message + "\n");
        }

        if (typeof external.menuArguments == 'undefined')
            yrprxBrowser.closeWindow();
    }
}
